from django.urls import path, include, re_path
from rest_framework_simplejwt.views import TokenVerifyView
from rest_framework_simplejwt.views import TokenRefreshView

from users.views import LoginView, RegisterView, UserView, FileView, AddrView

urlpatterns = [
    path('login/', LoginView.as_view(), name='login'),  # 登录
    path('register/', RegisterView.as_view()),  # 注册

    # 配置路由
    path('token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
    # 配置路由
    path('token/verify/', TokenVerifyView.as_view(), name='token_verify'),
    # 获取单个信息的路由
    path('users/<int:pk>/', UserView.as_view({
        "get": "retrieve"
    })),
    # 上传用户头像的路由
    path('<int:pk>/avatar/upload/', UserView.as_view({
        "post": "upload_avatar"
    })),
    # 添加和获取收货地址的路由
    path('address/', AddrView.as_view({
        "post": "create",
        "get": "list"
    })),
    # 修改和删除收货地址的路由
    path('address/<int:pk>/', AddrView.as_view({
        "delete": "destroy",
        "put": "update"
    })),
    # 设置默认收货地址的路由
    path('address/<int:pk>/default/', AddrView.as_view({
        "put": "set_default_addr"
    })),
]
